/**
 * Copyright (c) 2009-2016 https://github.com/zhanglongjian
 * Licensed under the Apache License, Version 2.0 (the "License");
 */
package com.ggy.utils;

import java.io.IOException;
import java.util.Properties;

import com.mysql.jdbc.log.LogUtils;

/**
 * <p>资源文件工具类</p>
 * <p> @createBy zhang longjian</p>
 * <p> @createTime 2017年7月27日 上午1:03:48 </p>
 * <p>TODO</p>
 */
public class PropertiesUtil {
	private Properties pro = new Properties();

	public PropertiesUtil(String filePath) {
		try {
			pro.load(this.getClass().getClassLoader()
			        .getResourceAsStream(filePath));
		} catch (IOException e) {
			Log4jUtil.error("读取资源文件失败");
			e.printStackTrace();
		}
	}
	/**
	 * 根据键或者得对应的值
	 * @param key
	 * @return
	 */
	public String getValue(String key) {
		return pro.getProperty(key);
	}
	public static void main(String[] args) {
		PropertiesUtil propertiesUtil=new PropertiesUtil("db.properties");
		System.out.println(propertiesUtil.getValue("driver"));
	}
}
